home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
clang
/
dtk_demo.zip
/
CURRDIR.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-12
|
2KB
|
70 lines
/* CURRDIR.C
* last mod.: 31-AUG-91
*/
#include <STDIO.H>
#include <STDLIB.H>
#include <STRING.H>
#include <L_DIR.H>
#include <L_DISK.H>
#include <L_TIME.H>
#include <L_STR.H>
/*-----------*/
void main(void)
{
Uchar high = high_drive();
Uchar drive = 'A';
Uchar last_drive;
Uchar current_directory[68];
int err_flag, num_floppies = num_floppy_drives();
if ( num_floppies == 1 )
last_drive = last_drive_used('A',&err_flag);
printf("Drive Current directory\n");
do {
if ( drive <= 'B' && num_floppies == 1
&& ( ( err_flag == -32 && drive == 'B' )
|| ( err_flag != 32 && drive != last_drive ) ) )
continue;
printf(" %c ",drive);
switch ( get_directory(drive,current_directory) )
{
case -1:
printf("NULL value for path.\n");
break;
case -2:
printf("Invalid drive.\n");
break;
case -3:
printf("Disk not present in floppy disk drive.\n");
break;
default:
puts(current_directory);
}
} while ( ++drive <= high );
/* randomly change to a another drive or subdirectory */
do {
drive = (Uchar)( 'A'
+ ((Uchar)time_elapsed_this_decade()%(high-'A'+1)) );
} while ( drive == 'B'
|| ( drive == 'A' && !bios_disk_present(0) ) );
get_directory(drive,current_directory);
if ( strlen(current_directory) > 3 )
{
/* is not root directory; change to parent subdirectory */
*strrchr_n(current_directory,'\\',1) = '\0';
if ( strlen(current_directory) == 2 )
strcat(current_directory,"\\");
printf("Changing to %s\n",current_directory);
}
set_directory(current_directory,TRUE);
/* TRUE = change drive if different */
get_directory(drive,current_directory);
printf("Current directory is %s\n",current_directory);
}